package com.fs.erp.api.basedata.service.Impl;

import com.fs.erp.api.basedata.entity.ProductBrand;
import com.fs.erp.api.basedata.mappers.ProductBrandMapper;
import com.fs.erp.api.basedata.service.ProductBrandService;
import com.fs.erp.api.basedata.vo.product.brank.QueryProductBrandVo;
import com.fs.erp.common.utils.Assert;
import com.fs.erp.mybatis.impl.BaseMpServiceImpl;
import com.fs.erp.mybatis.resp.PageResult;
import com.fs.erp.mybatis.utils.PageHelperUtil;
import com.fs.erp.mybatis.utils.PageResultUtil;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductBrandServiceImpl extends BaseMpServiceImpl<ProductBrandMapper, ProductBrand>
    implements ProductBrandService {

    @Override
    public PageResult<ProductBrand> query(int pageIndex, int pageSize, QueryProductBrandVo vo) {
        //断言，小于0报错
        Assert.greaterThanZero(pageIndex);
        Assert.greaterThanZero(pageSize);

        //开启分页(页码，页容量)
        PageHelperUtil.startPage(pageIndex,pageSize);
        List<ProductBrand> brands=getBaseMapper().queryBrand(vo);
        return PageResultUtil.convert(new PageInfo<>(brands));
    }

    @Override
    public ProductBrand findById(String id) {
        //todo
        return null;
    }


}
